﻿@page "/"
@using WorkFlow.Data
@using WorkFlow.Data.Model
@inject List<WorkFlowInfo> workFlowInfoList;
@inject List<ParameterEntity> parameterEntityList;
@inject CommentTool commentTool
@inject DataManager dataManager
<body>

    <h1>WorkFlow</h1>
    <div>
        WorkFlowName&nbsp;<input type="text" id="Search_WorkflowName" @bind="@_workFlowName">
        &nbsp;&nbsp;User&nbsp;<input type="text" id="Search_User" @bind="@_User">
        &nbsp;&nbsp;Status&nbsp;<select id="Search_Status" @bind="@_Status">
            <option selected="selected" value="-1">All</option>
            <option value="0">Wait</option>
            <option value="1">Runing</option>
            <option value="2">Compalte</option>
            <option value="3">Error</option>
            <option value="4">Stop</option>
        </select>
        &nbsp;&nbsp;Message&nbsp;<input type="text" id="Search_Message" @bind="@_Message">
        &nbsp;&nbsp;StartTime&nbsp;<input type="date" step="1" id="Search_StartTime" @bind="@_StartTime">
        &nbsp;&nbsp;EndTime&nbsp;<input type="date" step="1" id="Search_EndTime" @bind="@_EndTime">
        &nbsp;&nbsp;<button @onclick="@(()=>Search())" class="btn btn-primary btn-xs">Search</button>
    </div>
    <br>
    <table class="table">
        <thead>
            <tr>
                <th>Sno</th>
                <th>ID</th>
                <th>WorkFlowName</th>
                <th>User</th>
                <th>Status</th>
                <th>Message</th>
                <th>CreateTime</th>
                <th>Parameter</th>
            </tr>
        </thead>
        <tbody>
            @if (workFlowInfoList != null)
                @for (var i = 0; i < workFlowInfoList.Count; i++)
                {
                    WorkFlowInfo workFlowInfo = workFlowInfoList[i];
                    <tr>
                        <td>@(i+1)</td>
                        <td>@workFlowInfo.ID</td>
                        <td><a @onclick="()=>HiddenNav()" href="Detail/@workFlowInfo.ID" target="_Detail">@workFlowInfo.WorkFlowName</a></td>
                        <td>@workFlowInfo.User</td>
                        <td>@workFlowInfo.StatusStr</td>
                        <td>@workFlowInfo.Message</td>
                        <td>@workFlowInfo.CreateTime</td>
                        <td><a @onclick="()=>SearchParaters(workFlowInfo.ID)" href="" data-toggle="modal" data-target="#Paramerters">Parameters</a></td>
                    </tr>
                }
        </tbody>
    </table>

    <div class="modal fade" id="Paramerters" tabindex="-1" role="dialog" aria-labelledby="ParamertersLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="title">Business Parameters</h4>
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                </div>
                <div class="model-body">
                    <table class="table">
                        <thead>
                            <tr>
                                <th>Sno</th>
                                @*<th>ID</th>*@
                                <th>Name</th>
                                <th>Value</th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (parameterEntityList != null)
                                @for (var i = 0; i < parameterEntityList.Count; i++)
                                {
                                    ParameterEntity parameterEntity = parameterEntityList[i];
                                    <tr>
                                        <td>@(i+1)</td>
                                        @*<td>@parameterEntity.ID</td>*@
                                        <td>@parameterEntity.Name</td>
                                        <td>@parameterEntity.Value</td>
                                    </tr>
                                }
                        </tbody>
                    </table>
                </div>
                <div class="modal-footer">
@*                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary">Save</button>*@
                </div>
            </div>

        </div>
    </div>
</body>
